import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;

/**
 * @file FrmSet.java
 * @author tan
 * @mail 625844895@qq.com
 * @data 2014年4月22日 下午11:17:16
 * @description: Form 实现设置
 */
public class FrmSet extends Form implements CommandListener {
	private InfoCanvas mainScreen;
	private Display display;
	private String[] fontColor = { "黑色", "白色", "红色", "黄色", "绿色", "蓝色" };
	private String[] bgColor = { "白色", "黑色", "红色", "黄色", "绿色", "蓝色" };
	private String[] style = { "1", "2", "3" };
	private String[] face = { "1", "2", "3" };
	private String[] size = { "大", "中", "小" };
	private ChoiceGroup wordColor = new ChoiceGroup("文字", ChoiceGroup.POPUP, fontColor, null);
	private ChoiceGroup BGColor = new ChoiceGroup("背景", ChoiceGroup.POPUP, bgColor, null);
	private ChoiceGroup fontStyleGroup = new ChoiceGroup("字体样式", ChoiceGroup.POPUP, style, null);
	private ChoiceGroup fontFaceGroup = new ChoiceGroup("字体", ChoiceGroup.POPUP, face, null);
	private ChoiceGroup fontSizeGroup = new ChoiceGroup("字体大小", ChoiceGroup.POPUP, size, null);

	private Command cmdOK = new Command("保存", Command.OK, 1);
	private Command cmdCancel = new Command("取消", Command.CANCEL, 1);

	public FrmSet(InfoCanvas mainScreen, Display display) {
		super("设置");
		this.mainScreen = mainScreen;
		this.display = display;
		// TODO Auto-generated constructor stub
		this.append(wordColor);
		this.append(BGColor);
		this.append(fontFaceGroup);
		this.append(fontStyleGroup);
		this.append(fontSizeGroup);
		this.addCommand(cmdOK);
		this.addCommand(cmdCancel);

		this.setCommandListener(this);

	}

	public void commandAction(Command c, Displayable d) {
		// TODO Auto-generated method stub
		if (c == cmdOK) {
			int word = wordColor.getSelectedIndex();
			int BG = BGColor.getSelectedIndex();
			int face = fontFaceGroup.getSelectedIndex();
			int style = fontStyleGroup.getSelectedIndex();
			int size = fontSizeGroup.getSelectedIndex();
			mainScreen.setColor(word, BG);
			mainScreen.setFont(face, style, size);
			display.setCurrent(mainScreen);

		} else {
			display.setCurrent(mainScreen);
		}
	}

}
